package reference;

import java.lang.ref.PhantomReference;
import java.lang.ref.WeakReference;

/**
 * Author: hu
 * Date: 2022/3/25 10:47
 */
public class Stu {
    int num;
    String name;

    public Stu(int num, String name) {
        this.num = num;
        this.name = name;
    }

    @Override
    protected void finalize() throws Throwable {
        System.out.println("调用gc()方法，回收此对象"+this.getClass().getName());
    }

    @Override
    public String toString() {
        return "Stu{" +
                "num=" + num +
                ", name='" + name + '\'' +
                '}';
    }
}
